import request from '@/utils/request'

// 查询物联网模块列表
export function listIot(query) {
  return request({
    url: '/device/iot/list',
    method: 'get',
    params: query
  })
}

// 查询物联网模块详细
export function getIot(id) {
  return request({
    url: '/device/iot/' + id,
    method: 'get'
  })
}

// 新增物联网模块
export function addIot(data) {
  return request({
    url: '/device/iot',
    method: 'post',
    data: data
  })
}

// 修改物联网模块
export function updateIot(data) {
  return request({
    url: '/device/iot',
    method: 'put',
    data: data
  })
}

// 删除物联网模块
export function delIot(id) {
  return request({
    url: '/device/iot/' + id,
    method: 'delete'
  })
}

// 更新OTA
export function updateOTA(imei) {
  return request({
    url: '/device/iot/updateOTA/' + imei,
    method: 'post'
  })
}

// 设置IOT模块时间
export function setTime(imei) {
  return request({
    url: '/device/iot/setTime/' + imei,
    method: 'post'
  })
}

// 设置IOT模块心跳时间
export function setHeartupTime(imei, timeout) {
  return request({
    url: '/device/iot/setHeartupTime/' + imei,
    method: 'post',
    params: { timeout }
  })
}

// 设置IOT模块开关状态
export function setPwrSta(imei, pwrSta) {
  return request({
    url: '/device/iot/setPwrSta/' + imei,
    method: 'post',
    params: { pwrSta }
  })
}

// 查询物联网模块心跳记录
export function heartbeat(query) {
  return request({
    url: '/device/iot/heartbeat',
    method: 'get',
    params: query
  })
}